<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        其他配置
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../../css/main.css" media="all">
    <script type="text/javascript" src="../../../../lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="../../../../css/bootstrap.css">
    <link rel="stylesheet" href="../../../../lib/layui/css/layui_2.5.7.css">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
<div>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a><cite>首页</cite></a>
            <a><cite>物料信息</cite></a>
            <a><cite>其他配置</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                            style="line-height:30px">ဂ</i></a>
    </div>

    <div style="padding: 3%">
        <h4><b>1、日期类限制：</b></h4>
        <form class="layui-form layui-form-pane">
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <input type="hidden" name="kfDateRestrictId">
                    <div class="layui-inline layui-form-item">
                        <label class="layui-form-label">入库日期</label>
                        <div class="layui-input-inline">
                            <select name="joinType" lay-search="">
                                <option value="0">允许自定义</option>
                                <option value="1">禁止自定义</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline layui-form-item">
                        <label class="layui-form-label">出库日期</label>
                        <div class="layui-input-inline">
                            <select name="outType" lay-search="">
                                <option value="0">允许自定义</option>
                                <option value="1">禁止自定义</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline layui-form-item">
                        <label class="layui-form-label">移库日期</label>
                        <div class="layui-input-inline">
                            <select name="moveType" lay-search="">
                                <option value="0">允许自定义</option>
                                <option value="1">禁止自定义</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline layui-form-item">
                        <div style="width: 100px" class="layui-input-inline">
                            <button style="margin-bottom: 5px ; " class="layui-btn" type="button" lay-filter="sub1"
                                    lay-submit>
                                保存
                            </button>
                        </div>
                    </div>
                    <div style="height:30px;"></div>
                </div>


            </div>
        </form>


        <h4><b>2、物料单品指导价配置：</b></h4>
        <form class="layui-form layui-form-pane">
            <p>指导价 = 配件入库平均价 * （1 + 溢价指数） + 附加值</p>
            <input type="hidden" name="id">
            <div class="layui-tab-content">
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">溢价指数：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="premiumData" autocomplete="off"
                               placeholder="溢价指数" class="layui-input">
                    </div>
                    <label style="width: 300px" class="layui-form-label">注意：大于等于0，最多两位小数</label>
                </div>
                <br>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">附加值：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="additionalValue" autocomplete="off"
                               placeholder="附加值" class="layui-input">
                    </div>
                    <label style="width: 300px" class="layui-form-label">注意：大于等于0，最多两位小数</label>
                </div>
                <br>
                <div class="layui-inline layui-form-item">
                    <div style="width: 100px" class="layui-input-inline">
                        <button style="margin-bottom: 5px;" class="layui-btn" type="button" lay-filter="sub2"
                                lay-submit>
                            保存
                        </button>
                    </div>
                </div>
                <p style="color: red"><b>注意：指导价的模式为自动生成时，每次入库都会更改对应物料的指导价，这有可能不符合公司的预期！</b></p>
                <div style="height:30px;"></div>
            </div>


        </form>
    </div>


    <br><br><br><br><br><br>
</div>
</body>


<script type="text/javascript" src="../../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../../js/pub.js"></script>
<script type="text/javascript" src="../../../../lib/layui/layui2.5.7.js"></script>
<script type="text/javascript" src="../../../../js/vue.min.js"></script>
<!-- <script src="lib/layui/layui.js" charset="utf-8"></script> -->
<script src="../../../../js/x-layui.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element;//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        var form = layui.form;
        okLoading.close($);
    });
</script>


<script>
    let request = {
        url: "kf/otherConfig/getBaseData",
        method: "get",
        data:{
            userId: $userId
        }
    };

    sendRequest(request, (res) => {
        let form = layui.form;
        $("select[name=joinType]").val(res.data.kfDateRestrict.joinType);
        $("select[name=moveType]").val(res.data.kfDateRestrict.moveType);
        $("select[name=outType]").val(res.data.kfDateRestrict.outType);
        $("input[name=premiumData]").val(res.data.KfPartsPrice.premiumData);
        $("input[name=additionalValue]").val(res.data.KfPartsPrice.additionalValue);
        $("input[name=id]").val(res.data.KfPartsPrice.id);
        $("input[name=kfDateRestrictId]").val(res.data.kfDateRestrict.kfDateRestrictId);
        form.render('select');
    });


    layui.use(['form', 'layer'],
        function () {
            var $ = layui.jquery;
            var form = layui.form;
            var layer = layui.layer;

            //监听审批提交
            form.on('submit(sub1)',
                function (data) {
                    let form = data.field;
                    form.userId = $userId;
                    form.id = form.kfDateRestrictId;
                    let request = {
                        url: "kf/otherConfig/updateKfDateRestrict",
                        method: "post",
                        data: form
                    };
                    sendRequest(request, (res) => {
                        console.log(res);
                        if (res.code === 0) {
                            layer.alert("操作成功", {
                                icon: 6
                            });
                        } else {
                            layer.alert(data.msg, {
                                icon: 5
                            })
                        }
                    })

                });


            //监听审批提交
            form.on('submit(sub2)',
                function (data) {
                    let form = data.field;
                    form.userId = $userId;
                    let request = {
                        url: "kf/otherConfig/updateKfPartsPrice",
                        method: "post",
                        data: form
                    };
                    console.log(request);
                    sendRequest(request, (res) => {
                        console.log(res);
                        if (res.code === 0) {
                            layer.alert("操作成功", {
                                icon: 6
                            });
                        } else {
                            layer.alert(data.msg, {
                                icon: 5
                            })
                        }
                    })

                });

        })

</script>

</html>
